From 88490a29fe5aae0bf60864afd3807e5e8a67f88f Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Thu, 21 Jul 2005 13:59:08 +0000 Subject: [PATCH] Propagate guest MSR writes to machine MSRs immediately Right now, we have an exposure between the time the MSR is written and used by an instruction such as syscall. If there is a context switch and we do vmx_do_restore_msrs(), everything goes fine. But if we don't, then we execute the syscall with the wrong MSR. Signed-off-by: Yunhong Jiang Signed-off-by: Arun Sharma --- xen/arch/x86/vmx.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/vmx.c b/xen/arch/x86/vmx.c index e4cfb5e4c1..17c6d559bc 100644 --- a/xen/arch/x86/vmx.c +++ b/xen/arch/x86/vmx.c @@ -94,12 +94,16 @@ static void vmx_save_init_msrs(void) msr_content = msr->msr_items[VMX_INDEX_MSR_ ## address]; \ break -#define CASE_WRITE_MSR(address) \ - case MSR_ ## address: \ - msr->msr_items[VMX_INDEX_MSR_ ## address] = msr_content; \ - if (!test_bit(VMX_INDEX_MSR_ ## address, &msr->flags)){ \ - set_bit(VMX_INDEX_MSR_ ## address, &msr->flags); \ - }\ +#define CASE_WRITE_MSR(address) \ + case MSR_ ## address: \ + { \ + msr->msr_items[VMX_INDEX_MSR_ ## address] = msr_content; \ + if (!test_bit(VMX_INDEX_MSR_ ## address, &msr->flags)) { \ + set_bit(VMX_INDEX_MSR_ ## address, &msr->flags); \ + } \ + wrmsrl(MSR_ ## address, msr_content); \ + set_bit(VMX_INDEX_MSR_ ## address, &host_state->flags); \ + } \ break #define IS_CANO_ADDRESS(add) 1 @@ -1261,6 +1265,7 @@ static void mov_from_cr(int cr, int gp, struct cpu_user_regs *regs) CASE_SET_REG(EBP, ebp); CASE_SET_REG(ESI, esi); CASE_SET_REG(EDI, edi); + CASE_EXTEND_SET_REG case REG_ESP: __vmwrite(GUEST_RSP, value); regs->esp = value; -- 2.30.2